// pages/details/details.js
var urls = require("../../utils/urls.js");
var url = require("../../utils/url.js");
var interests;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    commentOne: {}
  },
  click_interests: function () {
    wx.navigateTo({
      url: '/pages/more_interests/more_interests?id=' + JSON.stringify(interests),
      success: function (res) {},
      fail: function (res) {},
      complete: function (res) {},
    })
  },
  //详情
  request_all_details: function (url) {
    var that = this;
    url({
      id: interests.id,
      success: function (res) {
        console.log(res.data);
        that.setData({
          commentOne: res.data
        })
        wx.setNavigationBarTitle({
          title: res.data.title
        })
      }
    });
  },
  //标签
  request_all_tags: function (url) {
    var that = this;
    url({
      id: interests.id,
      success: function (res) {
        console.log("tags_movie", res)
        that.setData({
          tags_list: res.data.tags
        })
      }
    });
  },
  //评论
  request_all_interests: function (url) {
    var that = this;
    url({
      id: interests.id,
      success: function (res) {
        console.log("tags_movie", res)
        that.setData({
          interests: res.data
        })
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    interests = options;
    console.log(options);
    var value = Number(options.value);
    //console.log(value)
    this.setData({
      value: value
    })
    if (options.type == "game") {
      this.request_all_details(url.details_game);
      this.request_all_tags(url.tags_game);
      this.request_all_interests(url.interests_game);
      return
    }
    if (options.type == "book") {
      this.request_all_details(url.details_book);
      this.request_all_tags(url.tags_book);
      this.request_all_interests(url.interests_book);
      return
    }
    if (options.type == "movie") {
      this.request_all_details(url.details_movie);
      this.request_all_tags(url.tags_movie);
      this.request_all_interests(url.interests_movie);
      return
    }
    if (options.type == "tv") {
      this.request_all_details(url.details_tv);
      this.request_all_tags(url.tags_tv);
      this.request_all_interests(url.interests_tv);
    }




  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})